
const obj = {
  a: { b: [1] },
  c: { d: { e: { f: { g: 2 } } } },
  d: { d: { e: { f: { g: { e: 1 } } } } }

}
function computedLevel(obj) {
  var res = 1;

  function computedLevel(obj, level) {
    var level = level ? level : 0;
    if (typeof obj === 'object') {
      for (var key in obj) {
        if (typeof obj[key] === 'object') {
          computedLevel(obj[key], level + 1);
        } else {
          res = level + 1 > res ? level + 1 : res;
        }
      }
    } else {
      res = level > res ? level : res;
    }
  }
  computedLevel(obj)

  return res

}

console.log(computedLevel(obj)) // 4